package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.flight.domain.CabinInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.service.ICabinInfoService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机票字典_舱位信息Controller
 * 
 * @author ruoyi
 * @date 2021-11-05
 */
@ControllerAdvice
@RestController
@RequestMapping("/cabinInfo")
public class CabinInfoController extends BaseController
{
    @Autowired
    private ICabinInfoService cabinInfoService;

    /**
     * 查询机票字典_舱位信息列表
     */
    //@PreAuthorize(hasPermi = "flight:info:list")
    @GetMapping("/list")
    public TableDataInfo list(CabinInfoDTO cabinInfoDTO)
    {
        startPage();
        List<CabinInfoDTO> list = cabinInfoService.selectCabinInfoList(cabinInfoDTO);
        return getDataTable(list);
    }

    /**
     * 导出机票字典_舱位信息列表
     */
    //@PreAuthorize(hasPermi = "flight:info:export")
    @Log(title = "机票字典_舱位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CabinInfoDTO cabinInfoDTO) throws IOException
    {
        List<CabinInfoDTO> list = cabinInfoService.selectCabinInfoList(cabinInfoDTO);
        ExcelUtil<CabinInfoDTO> util = new ExcelUtil<CabinInfoDTO>(CabinInfoDTO.class);
        util.exportExcel(response, list, "机票字典_舱位信息数据");
    }

    /**
     * 获取机票字典_舱位信息详细信息
     */
    //@PreAuthorize(hasPermi = "flight:info:query")
    @GetMapping(value = "/{cabinId}")
    public AjaxResult getInfo(@PathVariable("cabinId") Long cabinId)
    {
        return AjaxResult.success(cabinInfoService.selectCabinInfoById(cabinId));
    }

    /**
     * 新增机票字典_舱位信息
     */
    //@PreAuthorize(hasPermi = "flight:info:add")
    @Log(title = "机票字典_舱位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CabinInfoDTO cabinInfoDTO)
    {
        return toAjax(cabinInfoService.insertCabinInfo(cabinInfoDTO));
    }

    /**
     * 修改机票字典_舱位信息
     */
    //@PreAuthorize(hasPermi = "flight:info:edit")
    @Log(title = "机票字典_舱位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CabinInfoDTO cabinInfoDTO)
    {
        return toAjax(cabinInfoService.updateCabinInfo(cabinInfoDTO));
    }

    /**
     * 删除机票字典_舱位信息
     */
    //@PreAuthorize(hasPermi = "flight:info:remove")
    @Log(title = "机票字典_舱位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cabinIds}")
    public AjaxResult remove(@PathVariable Long[] cabinIds)
    {
        return toAjax(cabinInfoService.deleteCabinInfoByIds(cabinIds));
    }
}
